const Router = require('koa-router')

const categoryRouter = new Router({prefix:'/categories'})
const {
  getCateList,
  addCate,
  getCateById,
  updateCate,
  removeCateById,
  getAttr,
  addAttr,
  removeAttr,
  getAttrById,
  updateAttr
} = require('../controller/categoryController')
const { verifyAuth } = require('../middleware/authMiddleware')
//分类列表
categoryRouter.get('/',verifyAuth,getCateList)
//添加分类
categoryRouter.post('/', verifyAuth, addCate)
//查询分类byId
categoryRouter.get('/:id', verifyAuth, getCateById)
//编辑分类
categoryRouter.put('/:id', verifyAuth, updateCate)
//删除分类
categoryRouter.delete('/:id', verifyAuth, removeCateById)
//参数列表
categoryRouter.get('/:id/attributes', verifyAuth, getAttr)
//添加参数
categoryRouter.post('/:id/attributes', verifyAuth, addAttr)
//删除参数
categoryRouter.delete('/:cat_id/attributes/:attr_id', verifyAuth, removeAttr)
//查询参数
categoryRouter.get('/:cat_id/attributes/:attr_id', verifyAuth, getAttrById)
//编辑参数
categoryRouter.put('/:cat_id/attributes/:attr_id',verifyAuth,updateAttr)
module.exports = categoryRouter